package com.lianzhihui.romeex.ui.trade.fragment;

import android.annotation.SuppressLint;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.ConversionCoinPriceBean;
import com.lianzhihui.romeex.bean.ConversionConvetListBean;
import com.lianzhihui.romeex.bean.ConversionIndexBean;
import com.lianzhihui.romeex.config.AppConstants;
import com.lianzhihui.romeex.inter.DialogListener;
import com.lianzhihui.romeex.mvp.presenter.ExchangeFragmentPresnterImp;
import com.lianzhihui.romeex.mvp.view.ExchangeFragmentView;
import com.lianzhihui.romeex.ui.base.BaseFragment;
import com.lianzhihui.romeex.ui.trade.ExchangeDetailActivity;
import com.lianzhihui.romeex.ui.trade.adapter.ExchangeFragmentAdapter;
import com.lianzhihui.romeex.ui.trade.adapter.ExchangeInPopWindowAdapter;
import com.lianzhihui.romeex.ui.trade.adapter.ExchangeOutPopWindowAdapter;
import com.lianzhihui.romeex.utils.IntentUtils;
import com.lianzhihui.romeex.utils.NumberUtils;
import com.lianzhihui.romeex.utils.SoftKeyBoardListener;
import com.lianzhihui.romeex.widget.ZFEmptyRecyclerView;
import com.lianzhihui.romeex.widget.dialog.ExchangePasswordDialog;
import com.lianzhihui.romeex.widget.dialog.ExchangeSucDialog;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * ProjectName: romeex
 * Package: com.lianzhihui.romeex.ui.trade.fragment
 * ClassName: PledgeFramgent
 * Description: 兑换
 * Author: zhanghong
 * CreateDate: 2020/10/30 14:39
 * UpdateUser: 更新者：
 * UpdateDate: 2020/10/30 14:39
 * UpdateRemark: 更新说明：
 * Version: 1.0
 */
public class ExchangeFragment extends BaseFragment implements ExchangeFragmentView, OnRefreshListener, OnLoadMoreListener {

    @BindView(R.id.mySmartRefreshLayout)
    SmartRefreshLayout mySmartRefreshLayout;
    @BindView(R.id.myRootSmartRefreshLayout)
    SmartRefreshLayout myRootSmartRefreshLayout;
    private int selectOutIndex = 1;
    private int selectInIndex = 1;
    @BindView(R.id.myRecyclerView)
    ZFEmptyRecyclerView myRecyclerView;
    @BindView(R.id.icon_coin)
    ImageView iconCoin;
    @BindView(R.id.icon_coin1)
    ImageView iconCoin1;
    @BindView(R.id.input_num)
    TextView inputNum;
    @BindView(R.id.show_window)
    TextView showWindow;
    @BindView(R.id.show_window1)
    TextView showWindow1;
    @BindView(R.id.tv_coin)
    TextView tvCoin;
    @BindView(R.id.tv_coin1)
    TextView tvCoin1;
    @BindView(R.id.use_balance)
    TextView useBalance;
    @BindView(R.id.left_count)
    TextView leftCount;
    @BindView(R.id.tv_poundage)
    TextView tvPoundage;
    @BindView(R.id.right_count)
    TextView rightCount;
    @BindView(R.id.tv_in_count)
    TextView tvInCount;
    @BindView(R.id.icon_plus)
    ImageView icon_plus;
    private ExchangeFragmentAdapter exchangeFragmentAdapter;
    private ExchangeFragmentPresnterImp exchangeFragmentPresnterImp;
    private List<ConversionIndexBean.ConvertOutCoinListBean> convertOutCoinList;
    private List<ConversionIndexBean.ConvertInCoinListBean> convertInCoinList;
    private double exchangeRate = 0;
    private double coinPrice;
    private final int pageSize = 20;
    private ConversionIndexBean.FeeRateBean feeRate;
    private List<ConversionIndexBean.SlidingPointBean> slidingPoint;
    private ConversionConvetListBean exchangeList;
    private String myBalance;
    double trimPay;
    String coinGlobName;
    String coinGlobNameCobo;
    String coinGlobName1;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_exchange;
    }


    @Override
    protected void initView() {
        mySmartRefreshLayout.setOnLoadMoreListener(this);
        myRootSmartRefreshLayout.setOnRefreshListener(this);
        myRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        exchangeFragmentAdapter = new ExchangeFragmentAdapter(getActivity(), new ArrayList<>());
        exchangeFragmentAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                ConversionConvetListBean.ContentBean contentBean = exchangeList.getContent().get(position);
                IntentUtils.JumpToHaveObj(ExchangeDetailActivity.class, AppConstants.INTENT_EXCHANGE_DETAILS, contentBean);
            }
        });
        myRecyclerView.setAdapter(exchangeFragmentAdapter);
        exchangeFragmentPresnterImp = new ExchangeFragmentPresnterImp(getActivity(), this);
        SoftKeyBoardListener.setListener(getActivity(), new SoftKeyBoardListener.OnSoftKeyBoardChangeListener() {
            @Override
            public void keyBoardShow(int height) {
            }

            @Override
            public void keyBoardHide(int height) {
//                showDialog();
//                exchangeFragmentPresnterImp.requestConversionCoinPrice(convertOutCoinList.get(selectOutIndex).getCoinName(), convertOutCoinList.get(selectOutIndex).getCoinNameCobo(), convertInCoinList.get(selectInIndex).getCoinName());
            }
        });
        inputNum.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (s.toString().length() == 0) {
                    tvInCount.setText("0");
                    tvPoundage.setText(getString(R.string.text_exchange_poundage));
                    return;
                }
                try {
                    String pat = "^[0-9]+(\\.[0-9]{1,8})?$";
                    String inPutStr = s.toString();
                    boolean matches = Pattern.matches(pat, inPutStr);
                    if (!matches) {
//                        toast(getString(R.string.text_correct_money));
                        return;
                    }
                    if (Double.parseDouble(s.toString()) <= 0) {
                        return;
                    }
                    countPoundage();
                } catch (Exception e) {
                    toast(getString(R.string.text_correct_money));
                }

//                if (Double.parseDouble(myBalance) < Double.parseDouble(inputNum.getText().toString().trim())) {
//                    inputNum.setText(myBalance);
//                }

            }
        });
    }

    @Override
    protected void onFragmentFirstVisible() {
        super.onFragmentFirstVisible();
        showLoading("");
        exchangeFragmentPresnterImp.requestConversionIndex();
        exchangeFragmentPresnterImp.requestConversionConvetList(pageNum, pageSize);
    }

    @OnClick({R.id.tv_exchange,
            R.id.show_window,
            R.id.show_window1,
            R.id.tv_all,
            R.id.icon_coin,
            R.id.tv_coin,
            R.id.tv_coin1,
            R.id.icon_coin1,
            R.id.icon_plus})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_exchange:
                String numStr = inputNum.getText().toString().trim();
                if (TextUtils.isEmpty(numStr)) {
                    toast("请输入数量");
                    return;
                }
                String pat = "^[0-9]+(\\.[0-9]{1,8})?$";
                boolean matches = Pattern.matches(pat, numStr);
                if ((!matches) || Double.parseDouble(numStr) <= 0) {
                    toast(getString(R.string.text_correct_money));
                    return;
                }
                if (Double.parseDouble(myBalance) < Double.parseDouble(inputNum.getText().toString().trim())) {
                    toast(getResources().getString(R.string.text_not_enough));
                    return;
                }
                ExchangePasswordDialog dialog = new ExchangePasswordDialog(getActivity(), getResources().getString(R.string.text_exchange_comfirm));
                dialog.setTitleCenterHorizontal(Gravity.CENTER_HORIZONTAL);
                dialog.setData(convertOutCoinList.get(selectOutIndex - 1).getIcon(),
                        convertInCoinList.get(selectInIndex - 1).getIcon(),
                        inputNum.getText().toString().trim() + convertOutCoinList.get(selectOutIndex - 1).getCoinName(),
                        tvInCount.getText().toString().trim() + convertInCoinList.get(selectInIndex - 1).getCoinName());
                dialog.setListener(new DialogListener() {
                    @Override
                    public void onPassed() {
                        showLoading("");
                        trimPay = Double.parseDouble(inputNum.getText().toString().trim());
                        long pay = (long) (Double.parseDouble(inputNum.getText().toString().trim()) * AppConstants.BASE_ZERO);
                        exchangeFragmentPresnterImp.requestConversionConverte(String.valueOf(pay)
                                , convertOutCoinList.get(selectOutIndex - 1).getCoinName(),
                                convertOutCoinList.get(selectOutIndex - 1).getCoinNameCobo(),
                                convertInCoinList.get(selectInIndex - 1).getCoinName(),
                                convertInCoinList.get(selectInIndex - 1).getCoinNameCobo());
                        dialog.dismiss();
                    }

                    @Override
                    public void onFail() {

                    }
                });
                dialog.show();
                break;
            case R.id.show_window:
            case R.id.tv_coin:
            case R.id.icon_coin:
                showSelectShowWindow(showWindow, true);
                break;
            case R.id.show_window1:
            case R.id.icon_coin1:
            case R.id.tv_coin1:
                showSelectShowWindow(showWindow1, false);
                break;
            case R.id.tv_all:
                inputNum.setText(myBalance);
                break;
            case R.id.icon_plus:
                //兑换币种掉换位置
                int checkedIndex = -1;
                int checkedIndex1 = -1;
                for (int i = 0; i < convertOutCoinList.size(); i++) {
                    if (convertOutCoinList.get(i).getCoinNameAlias().equals(tvCoin1.getText().toString())) {
                        checkedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < convertInCoinList.size(); i++) {
                    if (convertInCoinList.get(i).getCoinNameAlias().equals(tvCoin.getText().toString())) {
                        checkedIndex1 = i;
                        break;
                    }
                }
                if (checkedIndex == -1 || checkedIndex1 == -1) {
                    return;
                }
                Glide.with(getActivity()).load(convertOutCoinList.get(checkedIndex).getIcon()).into(iconCoin);
                tvCoin.setText(convertOutCoinList.get(checkedIndex).getCoinNameAlias());
                selectOutIndex = checkedIndex + 1;
                Glide.with(getActivity()).load(convertInCoinList.get(checkedIndex1).getIcon()).into(iconCoin1);
                tvCoin1.setText(convertInCoinList.get(checkedIndex1).getCoinNameAlias());
                selectInIndex = checkedIndex1 + 1;
                exchangeFragmentPresnterImp.requestConversionCoinPrice(convertOutCoinList.get(checkedIndex).getCoinName(), convertOutCoinList.get(checkedIndex).getCoinNameCobo(), convertInCoinList.get(checkedIndex1).getCoinName());
//                countPoundage();
                break;

            default:
                break;
        }
    }


    private void showSelectShowWindow(View v, boolean flag) {
        @SuppressLint("InflateParams") View inflate = LayoutInflater.from(getActivity()).inflate(R.layout.pop_usdt_list, null, false);
        PopupWindow popupBigPhoto = new PopupWindow(inflate, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        RecyclerView viewById = inflate.findViewById(R.id.myRecyclerView);
        popupBigPhoto.setOutsideTouchable(true);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        viewById.setLayoutManager(layoutManager);
        BaseQuickAdapter adapter;
        if (flag) {
            adapter = new ExchangeOutPopWindowAdapter(getActivity(), convertOutCoinList);
        } else {
            adapter = new ExchangeInPopWindowAdapter(getActivity(), convertInCoinList);
        }
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                if (flag) {
                    ConversionIndexBean.ConvertOutCoinListBean convertOutCoinListBean = convertOutCoinList.get(position);
                    String s1 = convertOutCoinListBean.getCoinName() + convertOutCoinListBean.getCoinNameCobo();
                    ConversionIndexBean.ConvertInCoinListBean convertInCoinListBean = convertInCoinList.get(selectInIndex - 1);
                    String s2 = convertInCoinListBean.getCoinName() + convertInCoinListBean.getCoinNameCobo();
                    if (s1.equals(s2)) {
                        //相同币种
                        toast("相同币种");
                        return;
                    }
                    ConversionIndexBean.ConvertOutCoinListBean bean = convertOutCoinList.get(position);
                    Glide.with(getActivity()).load(bean.getIcon()).into(iconCoin);
                    tvCoin.setText(bean.getCoinNameAlias());
                    selectOutIndex = bean.getSort();
                    showDialog();
                    coinGlobName = bean.getCoinName();
                    coinGlobNameCobo = bean.getCoinNameCobo();
                    coinGlobName1 = convertInCoinList.get(selectInIndex - 1).getCoinName();
                    exchangeFragmentPresnterImp.requestConversionCoinPrice(coinGlobName, coinGlobNameCobo, coinGlobName1);
                } else {
                    ConversionIndexBean.ConvertOutCoinListBean convertOutCoinListBean = convertOutCoinList.get(selectOutIndex - 1);
                    String s1 = convertOutCoinListBean.getCoinName() + convertOutCoinListBean.getCoinNameCobo();
                    ConversionIndexBean.ConvertInCoinListBean convertInCoinListBean = convertInCoinList.get(position);
                    String s2 = convertInCoinListBean.getCoinName() + convertInCoinListBean.getCoinNameCobo();

                    if (s1.equals(s2)) {
                        //相同币种
                        toast("相同币种");
                        return;
                    }
                    ConversionIndexBean.ConvertInCoinListBean bean = convertInCoinList.get(position);
                    Glide.with(getActivity()).load(bean.getIcon()).into(iconCoin1);
                    tvCoin1.setText(bean.getCoinNameAlias());
                    selectInIndex = bean.getSort();
                    showDialog();
                    exchangeFragmentPresnterImp.requestConversionCoinPrice(convertOutCoinList.get(selectOutIndex - 1).getCoinName(), convertOutCoinList.get(selectOutIndex - 1).getCoinNameCobo(), bean.getCoinName());
                }

                popupBigPhoto.dismiss();
            }
        });
        if (flag) {
            ((ExchangeOutPopWindowAdapter) adapter).setSelectIndex(selectOutIndex);
        } else {
            ((ExchangeInPopWindowAdapter) adapter).setSelectIndex(selectInIndex);
        }

        viewById.setAdapter(adapter);
        popupBigPhoto.showAsDropDown(v, 0, 20);
    }

    private void showDialog() {
        showLoading("");
    }

    @Override
    public void setFailure() {
        dismissLoading();
        myRootSmartRefreshLayout.finishRefresh();
        mySmartRefreshLayout.finishLoadMore();
        mySmartRefreshLayout.setEnableLoadMore(true);
        myRootSmartRefreshLayout.setEnableRefresh(true);
    }

    /**
     * 计算手续费和滑点
     */
    private void countPoundage() {
        ConversionIndexBean.ConvertOutCoinListBean convertOutCoinListBean = convertOutCoinList.get(selectOutIndex - 1);
        ConversionIndexBean.ConvertInCoinListBean convertInCoinListBean = convertInCoinList.get(selectInIndex - 1);
        if ((convertOutCoinListBean.getCoinName().equals(getString(R.string.text_xusd)) &&
                convertInCoinListBean.getCoinName().equals("USDT"))
                || (convertOutCoinListBean.getCoinName().equals("USDT") &&
                convertInCoinListBean.getCoinName().equals(getString(R.string.text_xusd)))) {
            //兑换比例1：1，无手续费，无滑点
            //手续费
            tvPoundage.setText(MessageFormat.format("{0}{1}{2}", getString(R.string.text_exchange_poundage), 0, convertOutCoinListBean.getCoinName()));
            //滑点
            rightCount.setText(MessageFormat.format("{0}{1}", getString(R.string.text_exchange_slippage), "0%"));
            if (!inputNum.getText().toString().trim().isEmpty()) {
                String trim = inputNum.getText().toString().trim();
                double userValue = (double) (Double.parseDouble(trim) * exchangeRate);
                String s1 = String.format("%.8f", userValue);
                tvInCount.setText(NumberUtils.big8(s1));
            }
            return;
        }
        if (convertOutCoinListBean.getCoinName().equals("RET") || convertInCoinListBean.getCoinName().equals("RET")
                || (convertOutCoinListBean.getCoinName().equals("USDT") &&
                convertInCoinListBean.getCoinName().equals("USDT"))) {
            // USDT/XUSD兑换RET;RET兑换USDT/XUSD
            // 手续费值：（兑换前币种 x 兑换汇率 x （1 - 滑点））x 手续费
            // 滑点：
            //滑点
            double value = 0;
            if (!inputNum.getText().toString().trim().isEmpty()) {
                //滑点数值
                value = Double.parseDouble(inputNum.getText().toString().trim()) * coinPrice;
            }
            double slippage = 0;
            if (value <= slidingPoint.get(0).getPoint()) {
                slippage = slidingPoint.get(0).getRate();
            } else if (value > slidingPoint.get(1).getPoint() & value <= slidingPoint.get(2).getPoint()) {
                slippage = slidingPoint.get(1).getRate();
            } else if (value > slidingPoint.get(2).getPoint() & value <= slidingPoint.get(3).getPoint()) {
                slippage = slidingPoint.get(2).getRate();
            } else if (value > slidingPoint.get(3).getPoint() & value <= slidingPoint.get(4).getPoint()) {
                slippage = slidingPoint.get(3).getRate();
            } else if (value > slidingPoint.get(4).getPoint() & value <= slidingPoint.get(5).getPoint()) {
                slippage = slidingPoint.get(4).getRate();
            } else if (value > slidingPoint.get(5).getPoint() & value <= slidingPoint.get(6).getPoint()) {
                slippage = slidingPoint.get(5).getRate();
            } else if (value > slidingPoint.get(6).getPoint()) {
                slippage = slidingPoint.get(6).getRate();
            }
            rightCount.setText(MessageFormat.format("{0}{1}%", getString(R.string.text_exchange_slippage), slippage * 100));
            //手续费
            double poundage = 0;
            if (convertOutCoinListBean.getCoinName().equals("USDT") && convertInCoinListBean.getCoinName().equals(getString(R.string.text_xusd))) {
                poundage = feeRate.getUSDT2RUSD();
            } else if (convertOutCoinListBean.getCoinName().equals(getString(R.string.text_xusd)) && convertInCoinListBean.getCoinName().equals("USDT")) {
                poundage = feeRate.getRUSD2USDT();
            } else {
                poundage = feeRate.getOther();
            }
            if (!inputNum.getText().toString().trim().isEmpty()) {
                double poundageValue = Double.parseDouble(inputNum.getText().toString().trim()) * exchangeRate * (1 - slippage) * poundage;
                String s = String.format("%.8f", poundageValue);
//                poundageValue = Double.parseDouble(s);
                double userValue = Double.parseDouble(inputNum.getText().toString().trim()) * exchangeRate * (1 - slippage) * (1 - poundage);
                String s1 = String.format("%.8f", userValue);
//                userValue = Double.parseDouble(s1);
                tvInCount.setText(NumberUtils.big8(s1));
                tvPoundage.setText(MessageFormat.format("{0}{1}{2}", getString(R.string.text_exchange_poundage), NumberUtils.big8(s), convertInCoinListBean.getCoinName()));
            }
        }
    }

    /**
     * 兑换首页成功回调
     *
     * @param b
     */
    @Override
    public void responseConversionIndexSuccess(ConversionIndexBean b) {
        convertOutCoinList = b.getConvertOutCoinList();
        convertInCoinList = b.getConvertInCoinList();
        feeRate = b.getFeeRate();
        slidingPoint = b.getSlidingPoint();
        ConversionIndexBean.ConvertOutCoinListBean convertOutCoinListBean = b.getConvertOutCoinList().get(0);
        ConversionIndexBean.ConvertInCoinListBean convertInCoinListBean = b.getConvertInCoinList().get(0);
        Glide.with(getActivity()).load(convertOutCoinListBean.getIcon()).into(iconCoin);
        Glide.with(getActivity()).load(convertInCoinListBean.getIcon()).into(iconCoin1);
        tvCoin.setText(convertOutCoinListBean.getCoinNameAlias());
        tvCoin1.setText(convertInCoinListBean.getCoinNameAlias());
        dismissLoading();
        exchangeFragmentPresnterImp.requestConversionCoinPrice(convertOutCoinListBean.getCoinName(), convertOutCoinListBean.getCoinNameCobo(), convertInCoinListBean.getCoinName());

    }

    /**
     * 兑换汇率成功回调
     *
     * @param b
     */
    @Override
    public void responseConversionCoinPriceSuccess(ConversionCoinPriceBean b) {
        if (b != null && isAdded()) {
            exchangeRate = Double.parseDouble(b.getPrice());
            coinPrice = Double.parseDouble(b.getCoinPrice());
            myBalance = String.valueOf(b.getMyBalance());
            useBalance.setText(MessageFormat.format("{0}{1}{2}", getString(R.string.text_exchange_use), b.getMyBalance(), convertOutCoinList.get(selectOutIndex - 1).getCoinName()));
            leftCount.setText(MessageFormat.format("{0}{1}{2}={3}{4}", getString(R.string.text_exchange_price), 1, convertOutCoinList.get(selectOutIndex - 1).getCoinName(), b.getPrice(), convertInCoinList.get(selectInIndex - 1).getCoinName()));
            countPoundage();
        }
        dismissLoading();
    }

    /**
     * 兑换成功回调
     */
    @Override
    public void responseConversionConverteSuccess() {
        ExchangeSucDialog exchangeSucDialog = new ExchangeSucDialog(getActivity());
        myBalance = String.valueOf(Double.parseDouble(myBalance) - trimPay);
        useBalance.setText(MessageFormat.format("{0}{1}{2}", getString(R.string.text_exchange_use), NumberUtils.big8(myBalance), convertOutCoinList.get(selectOutIndex - 1).getCoinName()));
        exchangeSucDialog.setCallbackListener(new ExchangeSucDialog.Callback() {
            @Override
            public void confirm() {
                myRootSmartRefreshLayout.autoRefresh();
            }
        });
        dismissLoading();
        exchangeSucDialog.show();
    }

    /**
     * 兑换列表成功回调
     *
     * @param bean
     */
    @Override
    public void responseConversionConvetListSuccess(ConversionConvetListBean bean) {
        exchangeList = bean;
        if (bean != null) {
            if (pageNum == 1) {
                myRecyclerView.showEmptyView(bean.getContent().size(), pageNum);
                exchangeFragmentAdapter.setNewData(bean.getContent());
            } else {
                exchangeFragmentAdapter.addData(bean.getContent());
            }
        }
        pageNum++;
        myRootSmartRefreshLayout.finishRefresh();
        mySmartRefreshLayout.finishLoadMore();
        mySmartRefreshLayout.setEnableLoadMore(true);
        myRootSmartRefreshLayout.setEnableRefresh(true);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        myRootSmartRefreshLayout.setEnableRefresh(false);
        exchangeFragmentPresnterImp.requestConversionConvetList(pageNum, pageSize);
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        pageNum = 1;
        mySmartRefreshLayout.setEnableLoadMore(false);
        exchangeFragmentPresnterImp.requestConversionConvetList(pageNum, pageSize);
    }
}